<template>
  <div class="app-container table-app-container">
    <div class="fixed-table">
      <div class="fixed-table-actionbar">
        <TableFilter />
      </div>
      <PageableTable
        :loading="loading"
        :data="insideTableData"
        :total="totalElements"
        :page="currentPage"
        :page-size="pageSize"
        :table-height="tableHeight"
        class="fixed-table-table"
        :multiple-selected="multipleSelected"
        @page-change="onPageChange"
        @sort-change="onSortChange"
        @selection-change="onSelectionChange"
      >
        <el-table-column v-for="column in insideColumns" :key="column.key" :label="column.title" :prop="column.key" :sortable="column.sortable">
          <template slot-scope="scope">
            <column-render :render="column.render" :row="scope.row" :column="column" />
          </template>
        </el-table-column>
      </PageableTable>
    </div>
  </div>
</template>

<script>
// secondary package based on el-pagination
import { formatDate } from '@neu/biz-core/utils/utils'
// 表格查询组件独立编写，需要传递pageable-table实例的mixin方法filter
import TableFilter from './dutyTableFilter'
// 编辑实例组件独立编写，需要传递id属性，判断新建还是更新操作
import PageableTable from '@neu/biz-core/components/PageableTable'
import databind from '@neu/biz-core/mixins/databind'
import {
  page,
  remove
} from '@neu/dcom-ui/api/dutyArrangementResult'
export default {
  name: 'DutyArrangementResultPage',
  components: {
    TableFilter,
    PageableTable
    // ResultForm
  },
  // 加入混入，使表格混入更多的api操作
  mixins: [databind],
  props: {
    multipleSelected: {
      type: Boolean,
      default: false,
      required: false
    },
    isUser: {
      required: false,
      type: Boolean,
      default: true
    },
    userName: {
      required: false,
      type: String,
      default: ''
    }
  },
  data() {
    return {
      r: page,
      d: remove,
      insideColumns: [
        {
          title: '班次',
          key: 'classesName',
          sortable: 'custom'
        },
        {
          title: '开始时间',
          key: 'startTime',
          sortable: 'custom',
          render: (h, params) => {
            return (<span> { formatDate(params.row.startTime, 'YYYY-MM-DD HH:mm:ss') }</span>)
          }
        },
        {
          title: '结束时间',
          key: 'endTime',
          sortable: 'custom',
          render: (h, params) => {
            return (<span> { formatDate(params.row.endTime, 'YYYY-MM-DD HH:mm:ss') }</span>)
          }
        }
      ],
      // 编辑新增弹窗
      dialogFormVisible: false,
      // 编辑传递的ID
      editId: -1,
      // 检索条件
      searchObj: {
        s_deleteFlag: false,
        s_beforeStartTime: new Date().getTime(),
        s_isUser: this.isUser,
        s_userName: this.userName
      }
    }
  },
  created() {
    this.fetch()
  }
}
</script>
